#include <iostream>
#include <cstring>
using namespace std;
const int N = 200005;
int t, n;
int a[N];
int main(){
	cin >> t;
	while(t--){
		long long ans = 0;
		memset(a, 0, 4 * N);
		cin >> n;
		for (int i = 0; i < n; i++) cin >> a[i];
		for (int i = 1; i < n; i+=2){
			long long sum = a[i - 1] + a[i + 1] - a[i];
			if (sum > 0){
				if (a[i + 1] >= sum){
					a[i + 1] -= sum;
					ans += sum;
				}
				else{
					ans += sum;
					sum -= a[i + 1];
					a[i + 1] = 0; 
					a[i - 1] -= sum;
				}
			}
		}
		cout << ans << endl;
		
	}
	return 0;
}
